{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ```connect()``` function"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The connect function loads the configurations and initiates the connection with the website.\n",
    "\n",
    "In this section, we show what parameters are available and representative examples of how to connect to different websites.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Parameters\n",
    "\n",
    "* ```config_path``` is the path to the configuration file folder. There are two ways to load it. Details can be found in the previous configuraton file section.\n",
    "\n",
    "* ```update``` specifies if you want to pull the newest configuration files from the repo where existing configuration files are hosted.\n",
    "\n",
    "* ```_auth``` is the credentials to access the data passed through a dictionary. Details can be found in the authorization section.\n",
    "\n",
    "* ```_concurrency``` is how many queries you want to issue concurrently. By default it is one request/second. If you set it to 5, that means you want to issue five queries per second."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "## Examples\n",
    "\n",
    "Below shows some possible ways to call the connect function.\n",
    "\n",
    "For how to get the API credentials, please refer to our step-by-step tutorials [here](https://github.com/sfu-db/dataprep/tree/develop/examples) for some websites.\n",
    "\n",
    "* **dblp** \n",
    "\n",
    "```\n",
    "dblp_connector = connect('./dblp', _concurrency = 5)\n",
    "```\n",
    "```dblp``` is the simplest case where you do not need any credentials.\n",
    "In this case, we load from a local configuration file folder and issue five queries per second.\n",
    " \n",
    " \n",
    "* **YouTube**\n",
    "\n",
    "```\n",
    "auth_token = '<insert API key>'\n",
    "youtube_connector = connect('youtube', _auth={'access_token':auth_token}, _concurrency = 3)\n",
    "\n",
    "```\n",
    "\n",
    "```YouTube``` requires an API key to access the APIs. In this case, you need to first go to the youTube website, get the API key, and then get connected.\n",
    "Here, for the configuration files, we are using the existing ones in our repo.\n",
    "And you want to issue three queries per second.\n",
    "\n",
    "* **Twitter**\n",
    "\n",
    "```\n",
    "client_id = '<insert Consumer Key>'\n",
    "client_secret = '<insert Consumer Secret Key>'\n",
    "twitter_connector = connect(\"twitter\", _auth={\"client_id\":twitter_client_id, \"client_secret\":twitter_client_secret})\n",
    "```\n",
    "```Twitter``` uses OAuth2.0 for authentication, that needs both ```client_id``` and ```client_secret```.\n",
    "Here, for the configuration files, we are using the existing ones in our repo.\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
